<template>
    <div>
        <AccessoryItem
            v-show="isShowAtta"
            :isCreated="isCreated"
            :isInlineLayout="isInlineLayout"
            :dataList="attachments"
            @deleteItem="index => deleteItem(attachments, index)"
        />
        <AccessoryItem
            v-show="isShowDoc"
            :isCreated="isCreated"
            :isInlineLayout="isInlineLayout"
            :dataList="relationDocs"
            :areaName="areaName"
            isDoc
            @deleteItem="index => deleteItem(relationDocs, index)"
        />
    </div>
</template>

<script>
    import AccessoryItem from '@/components/atom/accessory-item-new';
           
    export default {
        name: 'AccessoryList',
        components: {
            AccessoryItem,
        },
        props: {
            // 附件列表
            attachments: {
                type: Array,
                default: () => ([]),
            },
            // 关联文档列表
            relationDocs: {
                type: Array,
                default: () => ([]),
            },
            // 相关数据区域，相关数据必传
            areaName: {
                type: String,
                default: 'doc1',
            },
            isCreated: { // 是否为创建态
                type: Boolean,
                default: true,
            },
            isInlineLayout: { // 是否横向排列
                type: Boolean,
                default: true,
            },
        },
        computed: {
            isShowAtta() {
                return this.attachments && this.attachments.length;
            },
            isShowDoc() {
                return this.relationDocs && this.relationDocs.length;
            },
        },
        methods: {
            // 删除附件某一项
            deleteItem(list, index) {
                list.splice(index, 1);
            },
        },
    };
</script>
